package com.itmg.factory;

import com.itmg.dao.BrandDAO;
import com.itmg.dao.CacheDAO;
import com.itmg.dao.CacheDataDAO;
import com.itmg.dao.CategoryDAO;
import com.itmg.dao.DataDAO;
import com.itmg.dao.KeywordsDAO;
import com.itmg.dao.TopImageDAO;
import com.itmg.dao.WebsiteDAO;

public class DAOFactory {
	
	private static CategoryDAO categoryDAO;
	private static CacheDAO cacheDAO;
	private static DataDAO dataDAO;
	private static WebsiteDAO websiteDAO;
	private static CacheDataDAO cacheDataDAO; 
	private static BrandDAO brandDAO;
	private static TopImageDAO topImageDAO;
	private static KeywordsDAO keywordsDAO;
	
	public synchronized static CategoryDAO getCategoryDAO(){
		if(categoryDAO == null){
			categoryDAO = (CategoryDAO)SpringBeanFactory.getBeanByID("categoryDAO");
		}
		return categoryDAO;
	}
	
	public synchronized static CacheDAO getCacheDAO(){
		if(cacheDAO == null){
			cacheDAO = (CacheDAO)SpringBeanFactory.getBeanByID("cacheDAO");
		}
		return cacheDAO;
	}
	
	public synchronized static DataDAO getDataDAO(){
		if(dataDAO == null){
			dataDAO = (DataDAO)SpringBeanFactory.getBeanByID("dataDAO");
		}
		return dataDAO;
	}
	
	public synchronized static WebsiteDAO getWebsiteDAO(){
		if(websiteDAO == null){
			websiteDAO = (WebsiteDAO)SpringBeanFactory.getBeanByID("websiteDAO");
		}
		return websiteDAO;
	}
	
	public synchronized static CacheDataDAO getCacheDataDAO(){
		if(cacheDataDAO == null){
			cacheDataDAO = (CacheDataDAO)SpringBeanFactory.getBeanByID("cacheDataDAO");
		}
		return cacheDataDAO;
	}
	
	public synchronized static TopImageDAO getTopImageDAO(){
		if(topImageDAO == null){
			topImageDAO = (TopImageDAO)SpringBeanFactory.getBeanByID("topImageDAO");
		}
		return topImageDAO;
	}
	
	public synchronized static BrandDAO getBrandDAO(){
		if(brandDAO == null){
			brandDAO = (BrandDAO)SpringBeanFactory.getBeanByID("brandDAO");
		}
		return brandDAO;
	}
	
	public synchronized static KeywordsDAO getKeywordsDAO(){
		if(keywordsDAO == null){
			keywordsDAO = (KeywordsDAO)SpringBeanFactory.getBeanByID("keywordsDAO");
		}
		return keywordsDAO;
	}
	
}
